<div class="container">
  

        <h1 id="pkg-overview">package syslog</h1>

        <p><code>import "log/syslog"</code>

        </p><p>
syslog 包提供一个简单的系统日志服务的接口。 It can send messages to the syslog daemon using UNIX
domain sockets, UDP or TCP.
</p>
<p>
Only one call to Dial is necessary. On write failures,
the syslog client will attempt to reconnect to the server
and write again.
</p>
<p>
The syslog package is frozen and is not accepting new features.
Some external packages provide more functionality. See:
</p>
<pre><a href="https://godoc.org/?q=syslog">https://godoc.org/?q=syslog</a></pre>


        
  


        
        

        

        

        
        
          
          
        

        
        


<p><a href="https://github.com/golang/go/blob/master/src/log/syslog/doc.go">doc.go</a> <a href="https://github.com/golang/go/blob/master/src/log/syslog/syslog.go">syslog.go</a> <a href="https://github.com/golang/go/blob/master/src/log/syslog/syslog_unix.go">syslog_unix.go</a> </p>

        
        

        
        

        
        
        
          <h2 data-kind="f" id="NewLogger">func <a href="https://github.com/golang/go/blob/master/src/log/syslog/syslog.go#L308" title="View Source">NewLogger</a>  </h2>
          <p>
NewLogger creates a log.Logger whose output is written to
the system log service with the specified priority. The logFlag
argument is the flag set passed through to log.New to create
the Logger.
</p>

          
  

        

        
        

        
          <h2 data-kind="t" id="Priority">type <a href="https://github.com/golang/go/blob/master/src/log/syslog/syslog.go#L24" title="View Source">Priority</a>  </h2>
          <p>
The Priority is a combination of the syslog facility and
severity. For example, LOG_ALERT | LOG_FTP sends an alert severity
message from the FTP facility. The default severity is LOG_EMERG;
the default facility is LOG_KERN.
</p>

          
          
          
  


          

          
        
          <h2 data-kind="t" id="Writer">type <a href="https://github.com/golang/go/blob/master/src/log/syslog/syslog.go#L76" title="View Source">Writer</a>  </h2>
          <p>
A Writer is a connection to a syslog server.
</p>

          
          
          
  


          
            <h3 data-kind="f" id="Dial">func <a href="https://github.com/golang/go/blob/master/src/log/syslog/syslog.go#L117" title="View Source">Dial</a>  </h3>
            <p>
Dial establishes a connection to a log daemon by connecting to
address raddr on the specified network. Each write to the returned
writer sends a log message with the given facility, severity and
tag.
If network is empty, Dial will connect to the local syslog server.
Otherwise, see the documentation for net.Dial for valid values
of network and raddr.
</p>

            
  
    <div class="panel-group">
    
      <div class="panel panel-default" id="example-Dial">
        <div class="panel-heading"><a class="accordion-toggle" data-toggle="collapse" href="#ex-Dial">Example</a></div>
        <div class="panel-collapse collapse" id="ex-Dial"><div class="panel-body">
          
          <p>Code:<span class="pull-right"><a href="?play=Dial">play</a> </span>
          </p><pre>sysLog, err := syslog.Dial("tcp", "localhost:1234",
    syslog.LOG_WARNING|syslog.LOG_DAEMON, "demotag")
if err != nil {
    log.Fatal(err)
}
fmt.Fprintf(sysLog, "This is a daemon warning with demotag.")
sysLog.Emerg("And this is a daemon emergency with demotag.")
</pre>
          
        </div></div>
      </div>
    
    </div>
  

          
            <h3 data-kind="f" id="New">func <a href="https://github.com/golang/go/blob/master/src/log/syslog/syslog.go#L106" title="View Source">New</a>  </h3>
            <p>
New establishes a new connection to the system log daemon. Each
write to the returned writer sends a log message with the given
priority and prefix.
</p>

            
  

          

          
            <h3 data-kind="m" id="Writer.Alert">func (*Writer) <a href="https://github.com/golang/go/blob/master/src/log/syslog/syslog.go#L199" title="View Source">Alert</a>  </h3>
            <p>
Alert logs a message with severity LOG_ALERT, ignoring the severity
passed to New.
</p>

            
  

          
            <h3 data-kind="m" id="Writer.Close">func (*Writer) <a href="https://github.com/golang/go/blob/master/src/log/syslog/syslog.go#L178" title="View Source">Close</a>  </h3>
            <p>
Close closes a connection to the syslog daemon.
</p>

            
  

          
            <h3 data-kind="m" id="Writer.Crit">func (*Writer) <a href="https://github.com/golang/go/blob/master/src/log/syslog/syslog.go#L206" title="View Source">Crit</a>  </h3>
            <p>
Crit logs a message with severity LOG_CRIT, ignoring the severity
passed to New.
</p>

            
  

          
            <h3 data-kind="m" id="Writer.Debug">func (*Writer) <a href="https://github.com/golang/go/blob/master/src/log/syslog/syslog.go#L241" title="View Source">Debug</a>  </h3>
            <p>
Debug logs a message with severity LOG_DEBUG, ignoring the severity
passed to New.
</p>

            
  

          
            <h3 data-kind="m" id="Writer.Emerg">func (*Writer) <a href="https://github.com/golang/go/blob/master/src/log/syslog/syslog.go#L192" title="View Source">Emerg</a>  </h3>
            <p>
Emerg logs a message with severity LOG_EMERG, ignoring the severity
passed to New.
</p>

            
  

          
            <h3 data-kind="m" id="Writer.Err">func (*Writer) <a href="https://github.com/golang/go/blob/master/src/log/syslog/syslog.go#L213" title="View Source">Err</a>  </h3>
            <p>
Err logs a message with severity LOG_ERR, ignoring the severity
passed to New.
</p>

            
  

          
            <h3 data-kind="m" id="Writer.Info">func (*Writer) <a href="https://github.com/golang/go/blob/master/src/log/syslog/syslog.go#L234" title="View Source">Info</a>  </h3>
            <p>
Info logs a message with severity LOG_INFO, ignoring the severity
passed to New.
</p>

            
  

          
            <h3 data-kind="m" id="Writer.Notice">func (*Writer) <a href="https://github.com/golang/go/blob/master/src/log/syslog/syslog.go#L227" title="View Source">Notice</a>  </h3>
            <p>
Notice logs a message with severity LOG_NOTICE, ignoring the
severity passed to New.
</p>

            
  

          
            <h3 data-kind="m" id="Writer.Warning">func (*Writer) <a href="https://github.com/golang/go/blob/master/src/log/syslog/syslog.go#L220" title="View Source">Warning</a>  </h3>
            <p>
Warning logs a message with severity LOG_WARNING, ignoring the
severity passed to New.
</p>

            
  

          
            <h3 data-kind="m" id="Writer.Write">func (*Writer) <a href="https://github.com/golang/go/blob/master/src/log/syslog/syslog.go#L173" title="View Source">Write</a>  </h3>
            <p>
Write sends a log message to the syslog daemon.
</p>

            
  

          
        
        


  <h2 id="pkg-note-bug">Bugs </h2><p><a href="https://github.com/golang/go/blob/master/src/log/syslog/doc.go#L19" title="View Source">☞</a> This package is not implemented on Windows. As the
syslog package is frozen, Windows users are encouraged to
use a package outside of the standard library. For background,
see https://github.com/golang/go/blob/master/issue/1108.</p><p><a href="https://github.com/golang/go/blob/master/src/log/syslog/doc.go#L24" title="View Source">☞</a> This package is not implemented on Plan 9.</p><p><a href="https://github.com/golang/go/blob/master/src/log/syslog/doc.go#L26" title="View Source">☞</a> This package is not implemented on NaCl (Native Client).



</p><div class="clearfix" id="x-footer">
  <div class="container">
    <a href="http://studygolang.com/" target="_blank">Go语言中文网</a>
    <span class="text-muted">|</span> <a href="http://golang.org/" target="_blank">Go Language</a>
    <span class="pull-right"><a href="#">Back to top</a></span>
  </div>
</div>
<script src="../assets/jquery-2.0.3.min.js"></script>
<script src="../assets/bootstrap.min.js"></script>
<script src="../assets/site.js"></script>


</div>